package com.example.mylibrarybase.yumengmeng08.utils.dialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.mylibrarybase.utils.LogUtils;

/**
 * Created by Administrator 于萌萌
 * 创建日期: 15:24 . 2016年06月24日
 * 描述: 这是一个 专门判断   订单类型的  工具类
 * <p>
 * <p>
 * 备注: 订单条目
 */
public class CheckStatus {
    //
    //订单条目状态
    //已经删除
    public static final int ALREADY_DELETED = -1;
    //等待买家付款   未付款0
    public static final int WAITING_FOR_BUYERS_TO_PAY = 0;
    //已付款未发货    1
    public static final int NOT_SHIPPED_SHELL_OUT = 1;
    //已发货未收货    已付款2
    public static final int WAITING_FOR_DELIVERY = 2;
    //等待买家评价    未评价3
    public static final int WAIT_FOR_EVALUATION = 3;
    //等待卖家同意    退换货4
    // public static final int WAITING_FOR_THE_SELLER_TO_AGREE  = 4;
    //已评价 4
    public static final int ALREADY_EVALUATED = 4;
    //已取消   已完成5
    public static final int CANCELED = 5;
    // 货站代收7
    public static final int FREIGHT_STATION = 7;
    // 货站已完成8
    public static final int FREIGHT_STATION_FNISH = 8;

    //左面
    public static final String CANCELLATION_OF_ORDER = "取消订单";
    public static final String DELETE_ORDERS = "删除订单";
    public static final String DELAYED_RECEIPT = "延时收货";

    //右面
    public static final String LIGHTNING_RECEIVING = "闪电收货";
    public static final String REMINDER_DELIVERY = "提醒发货";
    public static final String CONFIRM_RECEIPT = "确认收货";
    public static final String FREIGHT_STATION_SHOUHUO = "收货";


    public static final String PAYMENT = "付款";
    public static final String APPRAISE = "评价";

    /**
     * 我们 检查一下 过来的 状态码
     *
     * @param
     * @param status         json 解析出来的  状态 数字  比如说1 代表 等待买家付款   未付款
     * @param c              上下文
     * @param layoutPosition @return  当前 item号
     */
    public static String checkMode(String status, Context c, int layoutPosition) {


        switch (Integer.parseInt(status)) {
            case ALREADY_DELETED:
                status = "订单已删除";
                break;
            case WAITING_FOR_BUYERS_TO_PAY:
                status = "等待买家付款";
                break;
            case NOT_SHIPPED_SHELL_OUT:
                status = "已付款未发货";
                break;
            case WAITING_FOR_DELIVERY:
                status = "已发货未收货";
                break;
            case WAIT_FOR_EVALUATION:
                status = "等待买家评价";
                break;
//            case WAITING_FOR_THE_SELLER_TO_AGREE:
//                status = "等待卖家同意";
//                break;
            case ALREADY_EVALUATED:
                status = "已评价";
                break;
            case CANCELED:
                status = "已取消";
                break;
            case FREIGHT_STATION:
                status = "货站代收";
                break;
            case FREIGHT_STATION_FNISH:
                status = "货站代收已完成";
                break;


        }
        LogUtils.i("status" + status);
        return status;

    }

    /**
     * 检查 状态的 重载方法
     *
     * @param status    状态码
     * @param textView1 红色按钮的对象
     * @param textView2 蓝色按钮的对象
     */
    public static void checkMode(String status, TextView textView1, TextView textView2) {


        switch (Integer.parseInt(status)) {
            case ALREADY_DELETED:
                LogUtils.i("现在下面按钮的状态"+"左面"+"隐藏"+"\n"+"右面"+"隐藏");
                // status = "订单已删除";
                textView1.setVisibility(View.GONE);
                textView2.setVisibility(View.GONE);

                break;

            case WAITING_FOR_BUYERS_TO_PAY:
                LogUtils.i("现在下面按钮的状态"+"左面"+"显示"+"\n"+"右面"+"显示");
                // status = "等待买家付款";
                textView1.setVisibility(View.VISIBLE);
                textView2.setVisibility(View.VISIBLE);
                textView1.setText("取消订单");
                textView2.setText("付款");

                break;

            case WAITING_FOR_DELIVERY:
                LogUtils.i("现在下面按钮的状态"+"左面"+"显示"+"\n"+"右面"+"显示");
                // status = "发货未收货";
                textView1.setVisibility(View.VISIBLE);
                textView2.setVisibility(View.VISIBLE);
                textView1.setText("延时收货");
                textView2.setText("闪电收货");

                break;
            case WAIT_FOR_EVALUATION:
                LogUtils.i("现在下面按钮的状态"+"左面"+"隐藏"+"\n"+"右面"+"显示");
                // status = "等待买家评价";
                textView1.setVisibility(View.GONE);
                textView2.setVisibility(View.VISIBLE);
                textView2.setText("评价");
                break;

            case NOT_SHIPPED_SHELL_OUT:
                // status = "已发货未收货";
                LogUtils.i("现在下面按钮的状态"+"左面"+"隐藏"+"\n"+"右面"+"显示");
                textView1.setVisibility(View.GONE);
                textView2.setVisibility(View.VISIBLE);
                textView2.setText("提醒发货");
                break;
//            case WAITING_FOR_THE_SELLER_TO_AGREE:
//               // status = "等待卖家同意";
//                textView1.setVisibility(View.INVISIBLE);
//                textView2.setVisibility(View.INVISIBLE);
//                break;
            case ALREADY_EVALUATED :
            case CANCELED:
                // status = "已完成";
                LogUtils.i("现在下面按钮的状态"+"左面"+"隐藏"+"\n"+"右面"+"隐藏");
                textView1.setVisibility(View.GONE);
                textView2.setVisibility(View.GONE);
//                textView1.setText("被删掉");
//                textView2.setText("被删掉");
                break;
            case FREIGHT_STATION:
                // status = "已完成";
                LogUtils.i("现在下面按钮的状态"+"左面"+"隐藏"+"\n"+"右面"+"隐藏");
                textView1.setVisibility(View.GONE);
                textView2.setVisibility(View.VISIBLE);
//                textView1.setText("被删掉");
                textView2.setText("收货");
                break;
            case FREIGHT_STATION_FNISH:
                // status = "已完成";
                LogUtils.i("现在下面按钮的状态"+"左面"+"隐藏"+"\n"+"右面"+"隐藏");
                textView1.setVisibility(View.GONE);
                textView2.setVisibility(View.GONE);
//                textView1.setText("被删掉");
               // textView2.setText("代收收货");
                break;


        }


    }



    /**
     * 是订单条目使用的类
     * 判断 我点的是谁的确定  多少号
     *
     * @param c              上下文
     * @param result         集合
     * @param string         弹出框的 标题
     * @param which          确定 或者 取消
     * @param layoutPosition 号
     * @param callbacktag    回调
     */
//    public static void chekedStatusCode(Context c, List<OrderForm.ResultBean> result, String string, String which, final int layoutPosition, final callbacktag callbacktag) {
//
//        //如果 which 是确定
//        switch (which) {
//            case DialogUtils.CONFIRM:
//                OrderForm.ResultBean resultBean = result.get(layoutPosition);
//                String buttonName = "";
//                String url = "";
//                //如果点的是删除订单的确定
//                if (string.equals(DialogUtils.CANCEL_SETTITLE_ORDER_FORM)) {
//                    url = DeleteOrderRequest.DELETE_ORDER_URL;
//                    buttonName = string;
//                }
//                //延时收货
//                if (string.equals(DialogUtils.DELAY_PAYMENT)) {
//                    url = DeleteOrderRequest.DELAY_ORDER_URL;
//                    buttonName = string;
//                }
//                //闪电收货
//                if (string.equals(DialogUtils.LIGHTNING_RECEIVING_TIPS)) {
//                    url = DeleteOrderRequest.PAYMENT_ORDER_URL;
//                    buttonName = string;
//                }
//                //确认收货
//                if (string.equals(DialogUtils.CONFIRM_SETTITLE_ORDER_FORM)) {
//                    url = DeleteOrderRequest.PAYMENT_ORDER_URL;
//                    buttonName = string;
//                }
//                //提醒发货
//                if (string.equals(DialogUtils.REMINDER_DELIVERY)) {
//                    url = DeleteOrderRequest.URGE_ORDER_URL;
//                    buttonName = string;
//                }
//                //取消订单
//                if (string.equals(DialogUtils.CANCEL_SETTITLE_ORDER_FORM)) {
//                    url = DeleteOrderRequest.DELETE_ORDER_URL;
//                    buttonName = string;
//                }
//                //货站代收
//                if (string.equals(DialogUtils.FREIGHT_STATION)) {
//                    url = DeleteOrderRequest.FREIGHT_STATION;
//                    buttonName = string;
//                }
////                //评论
////                if (string.equals(DialogUtils.ASSESS)) {
////                    url = DeleteOrderRequest.ASSESS_URL;
////                    buttonName = string;
////                }
//
//                loadData(c, url, buttonName, resultBean, callbacktag);
//                break;
//
//
//        }
//
//
//    }




    /**
     *
     * 根据 你点的确定  来判断是否打开对应的 activity
     * @param c 上下文
     * @param result 订单数据集合
     * @param string 标题
     * @param which 确定
     * @param
     * @param callbackopenStartactivity 回调
     */
//    public static void chekedStatusCodestartActivity(Context c, OrderForm.ResultBean result, String string, String which, callbackopenStartactivity callbackopenStartactivity){
//        //如果 which 是确定
//        switch (which) {
//            case DialogUtils.CONFIRM:
//               // OrderForm.ResultBean resultBean = result.get(layoutPosition);
//                String buttonName = "";
//                String url = "";
//                //如果点的是评论的确定
//                if (string.equals(DialogUtils.ASSESS)) {
//                    callbackopenStartactivity.success();
//                }
//                   // url = DeleteOrderRequest.DELETE_ORDER_URL;
//                   // buttonName = string;
//                }
//    }
    /**
     * 是订单详情使用的方法  能弹出来对话框如果点确定
     * 判断 我点的是谁的确定  多少号
     *
     * @param c              上下文
     * @param resultBean      订单条目的详细数据
     * @param string         弹出框的 标题
     * @param which          确定 或者 取消
     * @param layoutPosition 号
     * @param callbacktag    回调
     */
//    public static void chekedStatusCode(Context c, OrderForm.ResultBean resultBean, String string, String which, final int layoutPosition, final callbacktag callbacktag) {
//
//        //如果 which 是确定
//        switch (which) {
//            case DialogUtils.CONFIRM:
//                String buttonName = "";
//                String url = "";
//                //如果点的是删除订单的确定
//                if (string.equals(DialogUtils.CANCEL_SETTITLE_ORDER_FORM)) {
//                    url = DeleteOrderRequest.DELETE_ORDER_URL;
//                    buttonName = string;
//                }
//                //延时收货
//                if (string.equals(DialogUtils.DELAY_PAYMENT)) {
//                    url = DeleteOrderRequest.DELAY_ORDER_URL;
//                    buttonName = string;
//                }
//                //闪电收货
//                if (string.equals(DialogUtils.LIGHTNING_RECEIVING_TIPS)) {
//                    url = DeleteOrderRequest.PAYMENT_ORDER_URL;
//                    buttonName = string;
//                }
//                //确认收货
//                if (string.equals(DialogUtils.CONFIRM_SETTITLE_ORDER_FORM)) {
//                    url = DeleteOrderRequest.PAYMENT_ORDER_URL;
//                    buttonName = string;
//                }
//                //货站代收确认收货
//                if (string.equals(DialogUtils.FREIGHT_STATION)) {
//                    url = DeleteOrderRequest.FREIGHT_STATION;
//                    buttonName = string;
//                }
//                //提醒发货
//                if (string.equals(DialogUtils.REMINDER_DELIVERY)) {
//                    url = DeleteOrderRequest.URGE_ORDER_URL;
//                    buttonName = string;
//                }
//                //取消订单
//                if (string.equals(DialogUtils.CANCEL_SETTITLE_ORDER_FORM)) {
//                    url = DeleteOrderRequest.DELETE_ORDER_URL;
//                    buttonName = string;
//                }
//                //评价
////                if (string.equals(DialogUtils.ASSESS)) {
////                    callbacktag.success();
////                    return;
//////                    url = DeleteOrderRequest.ASSESS_URL;
//////                    buttonName = string;
////                }
//
//                loadData(c, url, buttonName, resultBean, callbacktag);
//                break;
//
//
//        }
//
//
//    }



    /**
     * 访问网络的方法
     *
//     * @param c           上下文
//     * @param url         访问的接口功能
//     * @param string
//     * @param resultBean  集合
//     * @param callbacktag 回调
     */
//    private static void loadData(Context c, String url, String string, OrderForm.ResultBean resultBean, final callbacktag callbacktag) {
//
//        final Dialog dialog = DialogUtils.showLoading(c, R.string.being_loaded);
//        HashMap<String, String> orderHashMap = new HashMap<>();
//        orderHashMap.put("order_no", resultBean.order_no);
//        LogUtils.i("order_no" + resultBean.order_no);
//
//        /**
//         * 上下文  访问路径  集合 回调
//         */
//        NetMan.call(c, url, orderHashMap, new NetMan.CallListener() {
//            @Override
//            public void call_success(JSONObject result) {
//                if (dialog!=null)
//                dialog.dismiss();
////                String data1 = result.getString("data");
////                LogUtils.i("解析出来的data1" + data1.toString());
//                callbacktag.success();
//            }
//
//            @Override
//            public void call_error(int error_code, String err_msg) {
//                if (dialog!=null)
//                dialog.dismiss();
//                callbacktag.error(error_code,err_msg);
//            }
//        });
//    }

    public interface callbacktag {
        void success();
        void error(int error_code, String error_msg);
    }

    public interface callbackopenStartactivity {
        void success();
    }



    public static String inquiryState(String status) {

        String s0 = "报价进行中";
        String s1 = "报价已结束";

        if ("0".equals(status)) {
            return s0;
        } else {
            return s1;
        }


    }

}
